var cwd = process.cwd
var resolve = require('resolve')

module.exports = function tryRequire (dep) {
  var fromCwd
  try {
    fromCwd = resolve.sync(dep, { basedir: cwd })
  } catch (e) {
    if (fromCwd) {
      return require(fromCwd)
    } else {
      try {
        return require(dep)
      } catch (e) {}
    }
  }
}
